package bit_operation;
//https://leetcode.cn/leetbook/read/illustration-of-algorithm/5vk1l3/
public class LCR_133位1的个数 {
    //逐位判断
    public class Solution {
        public int hammingWeight(int n) {
            int res = 0;
            while(n != 0) {
                res += n & 1;
                n >>>= 1;
            }
            return res;
        }
    }
    public class Solution2 {
        public int hammingWeight(int n) {
            int res = 0;
            while(n != 0) {
                res++;
                n &= n - 1;
            }
            return res;
        }
    }
}
